package cn.huiyunche.admin.controller;

import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSON;

import cn.huiyunche.base.service.interfaces.BCitiesDistanceService;
import cn.huiyunche.base.service.model.BCitiesDistance;
import cn.huiyunche.base.service.vo.BCitiesDistanceVo;
import cn.huiyunche.base.service.vo.PageVo;
import cn.huiyunche.base.service.vo.Result;

/**
 * 计算 城市运距
 * @author Administrator
 *
 */
@RequestMapping("/citydis")
@Controller
public class BCitiesDistanceController {

	private static final Logger logger = LoggerFactory.getLogger(BCitiesDistanceController.class);
	
	@Autowired
	private BCitiesDistanceService bCitiesDistanceService = null;
	
	public BCitiesDistanceService getBCitiesDistanceService(){
		return this.bCitiesDistanceService;
	}
	
	/**
	 * 城市运距列表
	 * @param bCitiesDistanceVo
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/list", method = RequestMethod.GET)
	public Result<Map<String, Object>> list(PageVo page, BCitiesDistanceVo bCitiesDistanceVo){
		Result<Map<String, Object>> result = new Result<Map<String, Object>>(true, null, "数据加载成功");
		logger.info("select city distance list params : {}.", JSON.toJSONString(bCitiesDistanceVo));
		result.setData(this.getBCitiesDistanceService().list(page, bCitiesDistanceVo));
		return result;
	}
	
	/**
	 * 更新城市运距
	 * @param bAreaCityRatingVo
	 * @return
	 * @throws Exception
	 */
	@ResponseBody
	@RequestMapping(value = "/update", method = RequestMethod.POST)
	public Result<String> updateCityDistance(BCitiesDistance bCitiesDistance) throws Exception {
		logger.info("udpate city distance params bCitiesDistance : {}.", JSON.toJSONString(bCitiesDistance));
		return this.getBCitiesDistanceService().updateCityDistance(bCitiesDistance);
	}
	
}